package com.yuanrui;

public class Monster {
private String name;
    private int health;
    private int attack;
    private int defense;

    public Monster(String name, int health, int attack, int defense) {
        this.name = name;
        this.health = health;
        this.attack = attack;
        this.defense = defense;
    }

    public void attack(Monster target) {
        int damage = this.attack - target.defense;
        if (damage < 0) {
            damage = 0;
        }
        target.health -= damage;
        System.out.println(this.name + " attacks " + target.name + " for " + damage + " damage!");
    }

    public void printStats() {
        System.out.println("Name: " + this.name);
        System.out.println("Health: " + this.health);
        System.out.println("Attack: " + this.attack);
        System.out.println("Defense: " + this.defense);
    }

    public boolean isAlive() {
        return this.health > 0;
    }
}
